﻿using System;
using System.Collections.Generic;
using System.Text;
using EnvDTE;
using Microsoft.TeamFoundation.Client;

namespace TFSPlus.Commands
{
    public class RestoreTfsExplorerLocationStartup : IAddinUICommand
    {
        #region IAddinUICommand Members

        public void UISetup(EnvDTE80.DTE2 applicationObject, EnvDTE.AddIn addInInstance, EnvDTE80.Commands2 commands, object[] contextGUIDS)
        {
            
        }

        public void Startup(EnvDTE80.DTE2 applicationObject, EnvDTE.AddIn addInInstance)
        {
            Globals globals = applicationObject.Globals;
            if (globals.get_VariableExists("TfsStartNavigate"))
            {
                string tfsStartNavigate = (string)globals["TfsStartNavigate"];
                if (tfsStartNavigate != "")
                    TFSPlusCommon.NavigateTo(tfsStartNavigate);
            }
            else
            {
                globals["TfsStartNavigate"] = "";
                globals.set_VariablePersists("TfsStartNavigate", true);

            }
        }

        public EnvDTE.vsCommandStatus QueryStatus()
        {
            return vsCommandStatus.vsCommandStatusEnabled;
        }

        public void Exec()
        {
            
        }


        public void Disconnect(EnvDTE80.DTE2 applicationObject, AddIn addInInstance)
        {
            string tfsNavigateTo = TFSPlusCommon.GetCurrentNavigate();
            if (tfsNavigateTo != "")
            {
                applicationObject.Globals["TfsStartNavigate"] = tfsNavigateTo;
            }
        }

        #endregion
    }
}
